package com.wc.trainTest.气球的摆放顺序;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/26 13:47
 * @description https://acm.creative3605.com/contest/68/problem/M
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static String s;
    static String t;
    static int[] map = new int[128];

    public static void main(String[] args) {
        while (sc.hasNext()) {
            s = sc.next();
            t = sc.next();
            Arrays.fill(map, 'a', 'z' + 1, 0);
            for (char ch : t.toCharArray()) {
                map[ch]++;
            }
            for (char ch : s.toCharArray()) {
                while (map[ch]-- > 0)
                    out.print(ch);
            }

            for (int i = 'a'; i <= 'z'; i++) {
                if (map[i] > 0) {
                    char c = (char) i;
                    while (map[i]-- > 0) {
                        out.print(c);
                    }
                }
            }
            out.println();
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
